package com.ex3;

public class Consumer implements Runnable {//接收方

    private MessageQueue queue;

    public Consumer(MessageQueue queue) {
        this.queue = queue;
    }

    public void run() {
        try {
            // 从队列中取出消息
            String message = queue.takeMessage();
            System.out.println(message);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}